﻿using FreesenseSubAIS.ImageProcess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;

namespace FreesenseSubAIS.UI
{
    public partial class CamerConfig : RadForm
    {
        public CamerConfig()
        {
            InitializeComponent();
            imageBox1.CopyMode = true;
        }

        private void CamerConfig_Load(object sender, EventArgs e)
        {
            imageBox1.Image = ImageManage.Instance.FifoImage .Item2;

            double wscale = (double)imageBox1.Width / (double)ImageManage.Instance.FifoImage.Item2.Width;
            double hscal = (double)imageBox1.Height / (double)ImageManage.Instance.FifoImage.Item2.Height;

            imageBox1.SetZoomScale(wscale > hscal ? hscal : wscale, new System.Drawing.Point(0, 0));

            ImageManage.Instance.FifoImage.Item2.Dispose();
            ImageManage.Instance.FifoImage = null;
        }

        private void CamerConfig_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ImageManage.Instance.FifoImage.Item2 != null)
            {
                ImageManage.Instance.FifoImage.Item2.Dispose();
                ImageManage.Instance.FifoImage = null;
            }
        }
    }
}
